home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / autobanmanager.h < prev    next >
C/C++ Source or Header  |  2011-11-06  |  1KB  |  56 lines

  1. // FileZilla Server - a Windows ftp server
  2.  
  3. // Copyright (C) 2002-2007 - Tim Kosse <tim.kosse@gmx.de>
  4.  
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. #ifndef __AUTOBANMANAGER_H__
  20. #define __AUTOBANMANAGER_H__
  21.  
  22. class COptions;
  23. class CAutoBanManager
  24. {
  25. public:
  26.  
  27.     CAutoBanManager(COptions* pOptions);
  28.     virtual ~CAutoBanManager();
  29.  
  30.     void PurgeOutdated();
  31.  
  32.     bool IsBanned(const CStdString& ip);
  33.  
  34.     // Returns true if address got banned
  35.     bool RegisterAttempt(const CStdString& ip);
  36.  
  37. protected:
  38.  
  39.     static int m_refCount;
  40.     
  41.     struct t_attemptInfo
  42.     {
  43.         int attempts;
  44.         time_t time;
  45.     };
  46.  
  47.     static std::map<CStdString, time_t> m_banMap;
  48.     static std::map<CStdString, t_attemptInfo> m_attemptMap;
  49.  
  50.     static CCriticalSectionWrapper m_sync;
  51.  
  52.     COptions* m_pOptions;
  53. };
  54.  
  55. #endif //__AUTOBANMANAGER_H__
  56.